######
# Subs.pl for NewsDude
#
#  This script is Copyright (c) 2000 by Perlboy.org, Stuart Low all rights
#  reserved.  It may be used under the terms detailed in 
#  http://www.perlboy.org/scripts/license.html
#
#  YOU MAY MODIFY THIS SCRIPT PROVIDED YOU LEAVE THE ABOVE COPYRIGHT HEADING
#  INTACT.
#
#  Other than that, enjoy the script. I did it mainly for a dude on
#  alt.www.webmaster but also just for a kick on my last day of exams.
# 
#  If you want to get in touch, mail me at thedude@perlboy.org
#  I WILL NOT ANSWER SUPPORT QUESTIONS THOUGH.
#  This is mainly done due to the fact that I am a school student
#  and therefore cannot afford to offer support for my free scripts.
#
#  Once again. Visit alt.www.webmaster there are MANY a soul who will
#  happily help you.
#
#
#  If you own a business and use this on your clients sites
#  Could you please email me and tell me so that I can add your
#  business to a list of Web Design firms which use my script
#  Much appreciated
#  
#  Perlboy. (Stuart Low)
#  thedude@perlboy.org
#
# ------------------------------------------------------------------
##############################################################################


# Form Parsing.

sub FormParse
{

read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); 
if ($ENV{'QUERY_STRING'}) 
     { 
     $buffer = "$buffer\&$ENV{'QUERY_STRING'}"; 
     } 
@pairs = split(/&/,$buffer); 
 
foreach $pair (@pairs) 
     { 
     ($name,$value) = split(/=/,$pair); 
     $value =~ tr/+/ /; 
     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; 
     $FORM{$name} = $value; 
     } 

}



sub login_html {
     print qq~
<html>
<head>
<title>Admin Login</title>
</head>
<body bgcolor="#FFFFFF" BACKGROUND="http://www.amiganorththames.co.uk/Gfx/bg_stripe.co.uk">

<form method="POST" action="$admin_home">
<BR><BR>
<table border="0" cellpadding="1" cellspacing="1" width="372" ALIGN=CENTER
BGCOLOR="#003060">

<tr>
<td bgcolor="#004080" ALIGN=CENTER COLSPAN=3>
<FONT COLOR="#FFFFFF">
<b>Admin Login</B>
</FONT>
</td>

</tr>

<tr>
<td bgcolor="#004080" WIDTH=100 ALIGN=RIGHT VALIGN=MIDDLE>
<FONT COLOR="#FFFFFF">
Username:&nbsp;
</FONT>
</TD>

<TD bgcolor="#C0C0C0" ALIGN=CENTER>
 <input type="text" name="username" size="20"><br>
</TD>

<TD WIDTH=100 bgcolor="#004080">
</TD>

</TR>

<TR>
<TD bgcolor="#004080" ALIGN=RIGHT VALIGN=MIDDLE>
<FONT COLOR="#FFFFFF">
Password:&nbsp;
</FONT>
</TD>
<TD bgcolor="#C0C0C0" ALIGN=CENTER VALIGN=MIDDLE>
 <input type="text" name="login_password" size="20">
</TD>

<TD WIDTH=100 bgcolor="#004080">
</TD>

</TR>

<TR>
<TD COLSPAN=3 bgcolor="#004080"></TD>
</TR>

<TR>
<TD COLSPAN=3 "#004080" ALIGN=CENTER>
<input type="submit" value="Login"></font></td>
</TD>
</tr>
</table>
</FORM>

</body>
</html>
~;
}


sub error_html {
     ($error)=@_;
     print qq~
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<title>$sitename Admin</title>
</head>

<body bgcolor="#000000" text="#FFFFFF" link="#FFFF00"
vlink="#FFFF00" alink="#00FF00">

<table border="0">
    <tr>
        <td><p align="center"><font color="#FF0000" size="6"
        face="Arial"><strong><u>$sitename</u></strong></font></p>
        <p align="center"><font color="#FF0000" size="7">Error!</font></p>
        </td>
    </tr>
</table>
<p align="center">$error</p>

~;
     exit;
}

sub Date 
{ 
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6]; 
$year += "1900";
$RealMonth = $mon + 1;
$todays_date = "$mday\/$RealMonth\/$year"; 
$todays_time = "$hour:$min";
} 

1;
